<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>dom0事件</title>
</head>

<body>
  <button id="btn1">点击一下</button>
  <script>
    var btn = document.getElementById("btn1")
    btn.onclick = function (event) {
      console.log("点击完成")
      console.log(this)
    }
    // 新的功能需求，函数重复覆盖
    btn.onclick = function (event) {
      console.log("新功能")
      console.log(this)
    }
    // 解绑，将所有的功能重新写一遍
    btn.onclick = null
    btn.onclick = function () {
      console.log("点击完成")
      console.log(this)
      console.log("新功能")
    }

  </script>
</body>

</html>